package cn.zswltech.gruul.biz.comparator;

import cn.zswltech.gruul.common.entity.DisplayMenuDO;

import java.util.Comparator;

/**
 * 实现排序
 * Author: Jason 2018/8/3
 */
public class DisplayMenuDOComparator implements Comparator {
    @Override
    public int compare(Object arg0, Object arg1) {
        DisplayMenuDO obj1 = (DisplayMenuDO) arg0;
        DisplayMenuDO obj2 = (DisplayMenuDO) arg1;
        if (obj1.getSortNo() == null) {
            return -1;
        } else if (obj2.getSortNo() == null) {
            return 1;
        } else {
            int result = obj1.getSortNo().compareTo(obj2.getSortNo());
            if (result == 0) {
                return obj1.getGmtCreate().compareTo(obj2.getGmtCreate());
            } else {
                return result;
            }
        }
    }
}
